package com.dao;

import com.entity.Dept;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * @author cj
 * @date 2019/10/14
 */
public interface DeptDao {
    @Select("select id,deptname from dept where id =#{id}")
    Dept getDeptById(int id);


    @Select("select id,deptname from dept where id=#{deptid}")
    @Results({
            @Result(column = "id",property = "id",id = true),
            @Result(column = "deptname",property = "deptname"),
            @Result(column = "id",property = "employeeList",
                    many = @Many(select = "com.dao.EmployeeDao.getEmpsByDeptId")
            )
    })
    Dept getDeptWithEmpsById(int id);
}
